﻿using System.ComponentModel;
using System.Data;
using Newtonsoft.Json;

namespace Smatime.Web.Models
{
    public abstract class BaseEntity
    {
        [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(-1)]
        public long Id { get; set; }
        [JsonIgnore]
        public int RowStatus { get; set; }

        /// <summary>
        ///     Copy this object properties to the data row
        ///     Inherited classes must implement this method to communicate with ADO.NET data row
        /// </summary>
        /// <param name="row"></param>
        public virtual void ToDataRow(DataRow row)
        {

        }

        /// <summary>
        ///     Copy the data row data into this object
        ///     Inherited classes must implement this method to communicate with ADO.NET data row
        /// </summary>
        /// <param name="row"></param>
        public virtual BaseEntity FromDataRow(DataRow row)
        {
            return this;
        }
    }
}